import React, {useEffect, useState} from 'react';
import './index.css'
import u126 from './image/u126.png'
import u138 from './image/u138.png'
import u152 from './image/u152.png'
import http from "../../../util/http";
import {useNavigate} from "react-router-dom";

function Info(props) {
    let navigate = useNavigate();
    const [about, setAbout] = useState({});
    const [results, setResults] = useState({});
    const [honor, setHonor] = useState({});
    useEffect(() => {
        http.doGet('/doc/gethtml', {id: 390}).then(res => {
            if (res.status === 200) {
                setAbout({
                    title: res.title,
                    content: res.content.replace(/<[^>]*>/g, '').replaceAll("&nbsp;", "").replaceAll("\n","")
                })
            }
        })
        http.doGet('/doc/gethtml', {id: 405}).then(res => {
            if (res.status === 200) {
                setResults({
                    title: res.title,
                    content: res.content.replace(/<[^>]*>/g, '').replaceAll("&nbsp;", "").replaceAll("\n","")
                })
            }
        })
        http.doGet('/doc/gethtml', {id: 406}).then(res => {
            if (res.status === 200) {
                setHonor({
                    title: res.title,
                    content: res.content.replace(/<[^>]*>/g, '').replaceAll("&nbsp;", "").replaceAll("\n","")
                })
            }
        })
    }, [])

    function openUrl(docId) {
        if (docId && docId !== "") {
            navigate('/portal/details', {
                state: {docId, page: "home", text: ""}
            });
        }
    }

    return (
        <div className="info-main">
            <div className="info-up">
                <div className="info-up-content" onClick={() => openUrl(390)}>
                    <div className="info-up-content-header">关于总院</div>
                    <img src={u126} alt="图片" style={{width: 533, height: 230, top: 0, left: -71}}/>
                    <div className="info-up-content-text">
                        <div className="title">关于总院</div>
                        <div className="content">
                            <div className="content-text">{about.content}</div>
                        </div>
                        <div className="more">更多</div>
                    </div>
                </div>
                {/*<div className="info-up-separated"/>*/}
                <div className="info-up-content" onClick={() => openUrl(405)}>
                    <div className="info-up-content-header">主要业绩</div>
                    <img src={u138} alt="图片" style={{width: 530, height: 346, top: -73, right: 0}}/>
                    <div className="info-up-content-text">
                        <div className="title">主要业绩</div>
                        <div className="content">
                            <div className="content-text">{results.content}</div>
                        </div>
                        <div className="more">更多</div>
                    </div>
                </div>
            </div>
            <div className="info-down">
                <div className="info-down-left">
                    <img src={u152} alt="图片"/>
                    <span className="text">主要荣誉</span>
                </div>
                <div className="info-down-right" onClick={() => openUrl(406)}>
                    <div className="text">{honor.content}</div>
                    <div className="more">更多</div>
                </div>
            </div>
        </div>
    );
}

export default Info;